﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary.DAO;
using CrystalDecisions.Shared;


namespace mprsc
{
    public partial class ReportTechCopy : Form
    {
        TblJobsDAO jobDAO = new TblJobsDAO(Global.CONNECTION_STRING);

        public delegate void SendMessage(string Message);
        public SendMessage Sender; 

        public ReportTechCopy()
        {
            InitializeComponent();
            //Tao con tro toi hàm GetMessage
            Sender = new SendMessage(GetMessage);
        }

        //Hàm có nhiem vu lay tham so truyen vào
        private void GetMessage(string Message)
        {
            txt_jobID.Text = Message;
        }

        private void LoadTuchCopy()
        {
            Report_TechCopy rp = new Report_TechCopy();
            ParameterValues a = new ParameterValues();
            ParameterDiscreteValue b = new ParameterDiscreteValue();
            b.Value = txt_jobID.Text;
            a.Add(b);

            rp.DataDefinition.ParameterFields["@JobID"].ApplyCurrentValues(a);
            crystalReportViewer1.ReportSource = rp;
          
         

            //string id = txt_jobID.Text;
            //DataTable dt = jobDAO.reportJob1(Global.ConvertToInt(id));
            //rp.SetDataSource(dt);


            //foreach (DataRow dr in dt.Rows)
            //{
            //    lbJobNumber.Text = dr["JobID"].ToString();
            //    lbCustomerName.Text = dr["CustomerFullname"].ToString();
            //    lbManufactory.Text = dr["Manufacturer"].ToString();
            //    lbModel.Text = dr["Model"].ToString();
            //    lbIMEI.Text = dr["IMEINo"].ToString();
            //    lbNetwork.Text = dr["PhoneNetworkWith"].ToString();
            //    lbPass.Text = dr["LockPhone"].ToString();

            //    lbFail.Text = dr["FaultDescription"].ToString();
            //    lbAccessories.Text = dr["AccessoriesWithPhone"].ToString();
            //    lbInpection.Text = "";
            //    lbDateBook.Text = Convert.ToDateTime(dr["DateBook"].ToString()).ToString("dd/MM/yyyy");
            //    // lbBookBy.Text = dr["lbBookBy"].ToString();
            //    string idBookBy = dr["BookByID"].ToString();
            //    if (idBookBy == "1")
            //    {
            //        lbBookBy.Text = "Michael";

            //    }
            //    if (idBookBy == "2")
            //    {
            //        lbBookBy.Text = "Thao";
            //    }
            //    if (idBookBy == "3")
            //    {
            //        lbBookBy.Text = "Tung";
            //    }
            //    if (idBookBy == "4")
            //    {
            //        lbBookBy.Text = "Mi";
            //    }

            //    lbPhoneCotact.Text = dr["phonemobile"].ToString();

            //    lbHomePhone.Text = dr["phonehome"].ToString();

            //    lbWorkPhone.Text = dr["phonework"].ToString();


            //    lbEmail.Text = dr["emailaddress"].ToString();
            //}
           

        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
            LoadTuchCopy();
           
        }
    }
}
